﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Login : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}

	protected override void OnInit(EventArgs e)
	{
		base.OnInit(e);

		BtnLogin.Click += new EventHandler(BtnLogin_Click);
	}

	/// <summary>
	/// 登录按钮
	/// </summary>
	/// <![CDATA[2014-8-3 14:39:10]]>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void BtnLogin_Click(object sender, EventArgs e)
	{
		CheckLogin();
	}
	/// <summary>
	/// 检查登录
	/// </summary>
	/// <![CDATA[2014-8-3 14:39:34]]>
	private void CheckLogin()
	{
		DLL.User.Component clsUserComp = new DLL.User.Component(Page);
		DLL.UserGroup.Component clsUserGroupComp = new DLL.UserGroup.Component(Page);
		DLL.User.Entity clsUser = new DLL.User.Entity();

		if (clsUserComp.CheckLogin(TBUsername.Text, TBPassword.Text, ref clsUser))
		{
			Session["UserID"] = clsUser.ID;
			Session["ColumnIDs"] = clsUser.ColumnIDs;
			Session["WebColumnIDs"] = clsUser.WebColumnIDs;
			Session["DepartmentID"] = clsUser.DepartmentID;
			Session["QueryRight"] = clsUserGroupComp.GetOne(clsUser.UserGroupID).QueryRight;
			Response.Redirect("Main.aspx");
		}
		else
		{
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "用户名或密码错！");
		}
	}
}